import com.huang.dao.UserMapper;
import com.huang.pojo.User;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.util.List;

public class Mytest {
    @Test
    public void select() throws IOException {
//        String resources = "mybatis-config.xml";
//        InputStream rs = Resources.getResourceAsStream(resources);
//        SqlSessionFactory sqlsessionfactory = new SqlSessionFactoryBuilder().build(rs);
//        SqlSession sqlSession = sqlsessionfactory.openSession(true);
//        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
//        List<User> select = mapper.select();
//        for (User user : select) {
//            System.out.println(user);
//        }
//        sqlSession.close();
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserMapper userMapper = context.getBean("userMapper2", UserMapper.class);
        List<User> users = userMapper.select();
        for (User user : users) {
            System.out.println(user);
        }
    }
}
